//
//  CTUserView.m
//  ConstellationTalk_0.1
//
//  Created by riley on 15/4/30.
//  Copyright (c) 2015年 riley chu. All rights reserved.
//

#import "CTUserView.h"
#import "CTDebugManager.h"
#import "CTHeader.h"
#import "CTAppLanguage.h"
#import "CTLogin.h"
#import "CTFile.h"
#import "CTUser.h"
#import "CTImageProcessing.h"
#import "CTRequestUtil.h"
#import "CTTextManager.h"
#import "CTSegmentView.h"
#import "UIViewAdditions.h" 

#import "CTDataGenerator.h"

#import "CTUserPublishTableListView.h"
#import "CTUserPublishCollectionListView.h"
#import "CTUserSubjectsList.h"
#import "CTDeviceFunction.h"


typedef enum{
    CTUserViewSignTypeShowAll = 1,
    CTUserViewSignTypeShowHalf
}CTUserViewSignType;

@interface CTUserView ()<UIScrollViewDelegate,CTUserPublishCollectionListViewDelegate,CTUserPublishTableListViewDelegate,CTUserSubjectsListDelegate>
{
    
    UIScrollView * backGroundScrollView;
    UIView * backNodatagroundView;
    //登录背景
    UIView * loginBackGroundView;
    
    UIView * currentHeaderView;
    
    NSArray * userPublishArray;
    
    UIView * topView;
    UIImageView * headOriginalImageView;
    UIView * headShadowView;
    UIImageView * headThumbImageView;
    CTSegmentView * segmentView;
    
    CTUserViewPushFromType pushType;
    CTUserViewSignType signType;
    
    //用于第一次进入该界面
    BOOL firstEnter;
    
    //用于图片毛玻璃效果原图保留
    UIImage * headOriginalImage;
    
    
    //用于tabbar颜色渐变
    float offset_x;
    float offset_y;
    float offset_height;
    float offset_with;
    float tabbarHeight;
    
    
    CTUserPublishTableListView * publishTableListView;
    CTUserPublishCollectionListView * publishCollectionListView;
    CTUserSubjectsList * subjectListCollectionView;
    
    
    BOOL is_vip;
    BOOL is_self;
}

@end

@implementation CTUserView
@synthesize delegate,userItem;

- (void)dealloc
{
    [backNodatagroundView removeFromSuperview];
    backNodatagroundView = nil;
    
    [backGroundScrollView removeFromSuperview];
    backGroundScrollView = nil;
    
    currentHeaderView = nil;
    
    userPublishArray = nil;
    
    [loginBackGroundView removeFromSuperview];
    loginBackGroundView = nil;
    
    [publishTableListView removeFromSuperview];
    publishTableListView.delegate = nil;
    publishTableListView = nil;
    
    [publishCollectionListView removeFromSuperview];
    publishCollectionListView.delegate = nil;
    publishCollectionListView = nil;
    
    [subjectListCollectionView removeFromSuperview];
    subjectListCollectionView.delegate = nil;
    subjectListCollectionView = nil;
    
    
    headOriginalImage = nil;
    
    [headShadowView removeFromSuperview];
    headShadowView = nil;
    
    [segmentView removeFromSuperview];
    segmentView = nil;
    
    
    
    [headOriginalImageView removeFromSuperview];
    headOriginalImageView = nil;
    
    [headThumbImageView removeFromSuperview];
    headThumbImageView = nil;
    
    [topView removeFromSuperview];
    topView = nil;
   
    delegate = nil;
    userItem = nil;
    
     [CTDebugManager showDebugLogInfo:@"dealloc : CTUserView Is Removed!!!"];
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        firstEnter = YES;
        
        tabbarHeight = 64.0;
        signType = CTUserViewSignTypeShowHalf;
        
        self.frame = CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, CT_HEADER_SCREEN_HEIGHT);
        self.backgroundColor = CT_HEADER_WHITE_COLOR;
        
    }
    return self;
}

-(void)creatSubviews
{
    if (pushType == CTUserViewPushFromTypeDefault) {
        //默认页面
        if ([CTLogin isUserLoginState] == YES) {
            //已登录
            
            if ([CTUser isUserVip:userItem] == NO) {
                //普通用户
                [self creatLoginView:NO withSelf:YES];
            }else{
                //认证用户
                [self creatLoginView:YES withSelf:YES];
            }
        }else{
            //未登录
            [self creatNotLoginView];
        }
        
    }else{
        //其他页面推入
        
        if ([CTUser isUserSelf:userItem] == YES) {
            //是自己
            if ([CTUser isUserVip:userItem] == NO) {
                //普通用户
                [self creatLoginView:NO withSelf:YES];
            }else{
                //认证用户
                [self creatLoginView:YES withSelf:YES];
            }
        }else{
            //其他用户
            if ([CTUser isUserVip:userItem] == NO) {
                //普通用户
                [self creatLoginView:NO withSelf:NO];
            }else{
                //认证用户
                [self creatLoginView:YES withSelf:NO];
            }
        }
    }
}








-(void)creatLoginView:(BOOL)isVip withSelf:(BOOL)isSelf
{
    is_self = isSelf;
    is_vip = isVip;
    

    
    if (userPublishArray.count != 0) {
        [backNodatagroundView removeFromSuperview];
        backNodatagroundView = nil;
    }else{
        [self creatNoDataView];
    }
    
    
    if (pushType == CTUserViewPushFromTypeOther) {
        loginBackGroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, CT_HEADER_SCREEN_HEIGHT)];
        loginBackGroundView.backgroundColor = [UIColor clearColor];
    }else{
        loginBackGroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, CT_HEADER_SCREEN_HEIGHT-50)];
        loginBackGroundView.backgroundColor = [UIColor clearColor];
    }
    
    [self addSubview:loginBackGroundView];

    
    
    
    
    currentHeaderView = [self headView:isVip withSelf:isSelf];
   
    publishTableListView  = [[CTUserPublishTableListView alloc] initWithFrame:loginBackGroundView.bounds];
    publishTableListView.delegate = self;
    publishTableListView.pubUserDataArray = userPublishArray;
    [publishTableListView setHeadView: [self headView:isVip withSelf:isSelf]];
    [loginBackGroundView addSubview:publishTableListView];
    
    
    
    publishCollectionListView = [[CTUserPublishCollectionListView alloc] initWithFrame:loginBackGroundView.bounds];
    publishCollectionListView.delegate = self;
    publishCollectionListView.userPublishArray = userPublishArray;
    publishCollectionListView.hidden = YES;
    [loginBackGroundView addSubview:publishCollectionListView];
    
    
    
    if (isVip == YES) {
        subjectListCollectionView = [[CTUserSubjectsList alloc] initWithFrame:loginBackGroundView.bounds];
        subjectListCollectionView.delegate = self;
        subjectListCollectionView.hidden = YES;
        subjectListCollectionView.userSubArray = nil;
        [loginBackGroundView addSubview:subjectListCollectionView];
    }
    
    
    
    
    
    UIView * topBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 64)];
    topBackView.backgroundColor = [UIColor clearColor];
    [loginBackGroundView addSubview:topBackView];
    topView = [[UIView alloc]initWithFrame:topBackView.bounds];
    topView.backgroundColor = CT_HEADER_WHITE_COLOR;
    topView.alpha = 0.15;
    [topBackView addSubview:topView];
    
    UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-200.0)/2.0, 24, 200, 40)];
    titleLabel.textColor = CT_HEADER_WHITE_COLOR;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont systemFontOfSize:20];
    titleLabel.text = userItem.name;
    [topBackView addSubview:titleLabel];
    
    if (isSelf == YES) {
        UIButton * setBtn =[UIButton buttonWithType:UIButtonTypeCustom];
        setBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-44,24,44,44);
        [setBtn addTarget:self action:@selector(setBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [setBtn setTitleColor:CT_HEADER_WHITE_COLOR forState:UIControlStateNormal];
        [setBtn setBackgroundImage:[UIImage imageNamed:@"settings"] forState:UIControlStateNormal];
        [topBackView addSubview:setBtn];
    }else{
        
        UIButton * attenBtn =[UIButton buttonWithType:UIButtonTypeCustom];
        attenBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-78,22,88,44);
        [attenBtn addTarget:self action:@selector(attentionBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [attenBtn setTitleColor:CT_HEADER_WHITE_COLOR forState:UIControlStateNormal];
        attenBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [topBackView addSubview:attenBtn];
        
        if ([userItem.following isEqualToString:@"0"]) {
            //未关注
            [attenBtn setTitle:@"加关注" forState:UIControlStateNormal];
            attenBtn.tag = 0;
        }else{
            attenBtn.tag = 1;
            [attenBtn setTitle:@"取消关注" forState:UIControlStateNormal];
        }
        
    }
    
    //如果是其他页面推入 则显示返回按钮
    if (pushType == CTUserViewPushFromTypeOther) {
        UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        backBtn.frame = CGRectMake(0, 20, 44, 44);
        [backBtn setTitleColor:CT_HEADER_WHITE_COLOR forState:UIControlStateNormal];
        [backBtn setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [backBtn addTarget:self action:@selector(backBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [topBackView addSubview:backBtn];
    }
    
    
}



-(UIView *)headView:(BOOL)isVip withSelf:(BOOL)isSelf
{
    UIView * headBackGroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 0)];
    
    if (isVip == YES) {
        headOriginalImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, CT_HEADER_SCREEN_WIDTH, 335.0)];
    }else{
        headOriginalImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, CT_HEADER_SCREEN_WIDTH, 335.0 - 77 + 25)];
    }
    
    offset_x = headOriginalImageView.frame.origin.x;
    offset_y = headOriginalImageView.frame.origin.y;
    offset_with = headOriginalImageView.frame.size.width;
    offset_height = headOriginalImageView.frame.size.height;
    
    if ([[CTTextManager shareInstance] isBlankString:userItem.profile_image_url] == YES) {
        headOriginalImageView.image = [CTImageProcessing blurryImage:[UIImage imageNamed:@"head"] withBlurLevel:0.1];
    }else{
        
       
        headOriginalImage = [CTRequestUtil requestImageWithUrl:userItem.profile_image_url];
        headOriginalImage = [CTRequestUtil requestImageWithUrl:userItem.profile_image_url];
        headOriginalImage = [CTRequestUtil requestImageWithUrl:userItem.profile_image_url];
        headOriginalImageView.image = [CTImageProcessing blurryImage:headOriginalImage withBlurLevel:0.4];
        
//                [CTRequestUtil requestImgWithUrl:userItem.profile_image_url withCompletionSuccessHandler:^(UIImage *img) {
//                    dispatch_async(dispatch_get_main_queue(), ^{
//                        headOriginalImageView.image = img;
//                        headOriginalImage = img;
//                        headOriginalImageView.image = [CTImageProcessing blurryImage:headOriginalImage
//                                                                       withBlurLevel:0.4];
//                    });
//                } withFailedHandler:^(NSError *error) {
//        
//                }];
        
    }
    [headBackGroundView addSubview:headOriginalImageView];
    
    headShadowView = [[UIView alloc] initWithFrame:headOriginalImageView.bounds];
    headShadowView.backgroundColor = [UIColor blackColor];
    headShadowView.alpha = 0.3;
    [headOriginalImageView addSubview:headShadowView];
    
    headThumbImageView = [[UIImageView alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-77)/2.0, 64+26, 77, 77)];
    headThumbImageView.layer.cornerRadius = 77/2.0;
    headThumbImageView.layer.masksToBounds = YES;
    if ([[CTTextManager shareInstance] isBlankString:userItem.profile_image_url_thumb] == YES) {
        headThumbImageView.image = [UIImage imageNamed:@"head"];
    }else{
        
        [CTRequestUtil requestImgWithUrl:userItem.profile_image_url_thumb withCompletionSuccessHandler:^(UIImage *img) {
            headThumbImageView.image = img;
        } withFailedHandler:^(NSError *error) {
            
        }];
    //  headThumbImageView.image = [CTRequestUtil requestImageWithUrl:userItem.profile_image_url_thumb];
    }
    [headBackGroundView addSubview:headThumbImageView];
    
    if ([userItem.gender isEqualToString:@"1"]) {
        UIImageView * genderImageView = [[UIImageView alloc] initWithFrame:CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0+headThumbImageView.frame.size.width/2.0-21-5,64+26+77-21,21,21)];
        genderImageView.image = [UIImage imageNamed:@"xingbie_male"];
        [headBackGroundView addSubview:genderImageView];
    }else if ([userItem.gender isEqualToString:@"2"]){
        UIImageView * genderImageView = [[UIImageView alloc] initWithFrame:CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0+headThumbImageView.frame.size.width/2.0-21-5,64+26+77-21,21,21)];
        genderImageView.image = [UIImage imageNamed:@"xingbie_female"];
        [headBackGroundView addSubview:genderImageView];
    }
    
    
    // vip的图标
    if (isVip == YES) {
        UIImageView * vipImageview = [[UIImageView alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-77)/2.0+5, 64+26+77+10, 13, 13)];
        vipImageview.image = [UIImage imageNamed:@"v"];
        [headBackGroundView addSubview:vipImageview];
        
        UILabel * vipLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-77)/2.0+5+13+3, 64+26+77+11,100, 12)];
        vipLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_vipLabel" withValue:nil withTable:@"Language"];
        vipLabel.textColor = CT_HEADER_WHITE_COLOR;
        vipLabel.font = [UIFont systemFontOfSize:12];
        [headBackGroundView addSubview:vipLabel];
        
    }else{
        
    }
    
    
    
    
    //    userItem.sign= @"最近看到好几篇文章，谈国内创业地标，有赞赏，也有批判，其中几篇都提到杭州，却无不充盈溢美之词，但杭州是否真能盛名之下其实相副？";
    //签名
    UILabel * signLabel;
    if ([[CTTextManager shareInstance] isBlankString:userItem.sign] == YES) {
        //没有签名
        signLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-230)/2.0, 64+26+77+11+12+15, 230, 12)];
        signLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_sign" withValue:nil withTable:@"Language"];
        signLabel.font = [UIFont systemFontOfSize:12];
        signLabel.textColor = CT_HEADER_WHITE_COLOR;
        signLabel.textAlignment = NSTextAlignmentCenter;
        [headBackGroundView addSubview:signLabel];
    }else{
        //有签名
        if (userItem.sign.length <= 19) {
            signLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-230)/2.0, 64+26+77+11+12+15, 230, 12)];
            signLabel.text = userItem.sign;
            signLabel.font = [UIFont systemFontOfSize:12];
            signLabel.textColor = CT_HEADER_WHITE_COLOR;
            signLabel.textAlignment = NSTextAlignmentCenter;
            [headBackGroundView addSubview:signLabel];
        }else{
            
            
            if (signType == CTUserViewSignTypeShowHalf) {
                signLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-230)/2.0, 64+26+77+11+12+15, 230, 12)];
                signLabel.text = [userItem.sign substringToIndex:19];
                signLabel.font = [UIFont systemFontOfSize:12];
                signLabel.textColor = CT_HEADER_WHITE_COLOR;
                signLabel.textAlignment = NSTextAlignmentCenter;
                [headBackGroundView addSubview:signLabel];
                
                
                UIImageView * showSignImagView = [[UIImageView alloc] initWithFrame:CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0 + signLabel.frame.size.width/2.0 + 15, 64+26+77+11+12+15+2, 12, 7)];
                showSignImagView.image = [UIImage imageNamed:@"xiala_user"];
                [headBackGroundView addSubview:showSignImagView];
                
                UIButton * showSignBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                showSignBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0 + signLabel.frame.size.width/2.0 + 15, 64+26+77+11+12, 50, 60);
                [showSignBtn addTarget:self action:@selector(showSignBtnAction:) forControlEvents:UIControlEventTouchUpInside];
                [headBackGroundView addSubview:showSignBtn];
                showSignBtn.tag = CTUserViewSignTypeShowHalf;
                
                
            }else{
                
                signLabel = [[UILabel alloc] initWithFrame:CGRectZero];
                [signLabel setNumberOfLines:0];
                signLabel.lineBreakMode = NSLineBreakByWordWrapping;
                CGSize labelSize;
                labelSize = [userItem.sign sizeWithFont:[UIFont systemFontOfSize:12] constrainedToSize:CGSizeMake(230, 1000) lineBreakMode:NSLineBreakByWordWrapping];
                signLabel.frame = CGRectMake((CT_HEADER_SCREEN_WIDTH-230)/2.0, 64+26+77+11+12+15,labelSize.width, labelSize.height);
                signLabel.text = userItem.sign;
                signLabel.font = [UIFont systemFontOfSize:12];
                signLabel.textColor = CT_HEADER_WHITE_COLOR;
                signLabel.textAlignment = NSTextAlignmentLeft;
                [headBackGroundView addSubview:signLabel];
                
                
                UIImageView * showSignImagView = [[UIImageView alloc] initWithFrame:CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0 + signLabel.frame.size.width/2.0 + 15, 64+26+77+11+12+15+2, 12, 7)];
                showSignImagView.image = [UIImage imageNamed:@"shangla_user"];
                [headBackGroundView addSubview:showSignImagView];
                
                UIButton * showSignBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                showSignBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0 + signLabel.frame.size.width/2.0 + 15, 64+26+77+11+12, 50, 60);
                [showSignBtn addTarget:self action:@selector(showSignBtnAction:) forControlEvents:UIControlEventTouchUpInside];
                [headBackGroundView addSubview:showSignBtn];
                showSignBtn.tag = CTUserViewSignTypeShowAll;
                
                
                
                //重新定义背景图片的大小
                CGRect rect = headOriginalImageView.frame;
                rect.origin.x = -(signLabel.frame.size.height - 12)/2.0;
                rect.size.height += (signLabel.frame.size.height - 12);
                rect.size.width  += (signLabel.frame.size.height - 12);
                headOriginalImageView.frame = rect;
                headShadowView.frame = headOriginalImageView.bounds;
                
                offset_x = headOriginalImageView.frame.origin.x;
                offset_y = headOriginalImageView.frame.origin.y;
                offset_with = headOriginalImageView.frame.size.width;
                offset_height = headOriginalImageView.frame.size.height;
                
//                //重新定义的scroll view的contentsize大小
//                CGSize contenSize = userScrollView.contentSize;
//                contenSize.height += (signLabel.frame.size.height - 12);
//                userScrollView.contentSize = contenSize;
            }
            
        }
    }
    
    
    
    
    
    
    
    //关注&粉丝
    
    UIImageView * fenxianImageView = [[UIImageView alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH - 1)/2.0, signLabel.frame.origin.y+signLabel.frame.size.height+20, 1, 18)];
    fenxianImageView.image = [UIImage imageNamed:@"fengexian"];
    [headBackGroundView addSubview:fenxianImageView];
    
    
    
    float numeberCount;
    if (userItem.followers_count.length == 1) {
        numeberCount = 10;
    }else if(userItem.followers_count.length == 2){
        numeberCount = 21;
    }else if(userItem.followers_count.length == 3){
        numeberCount = 31;
    }else if(userItem.followers_count.length == 4){
        numeberCount = 41;
    }else if(userItem.followers_count.length == 5){
        numeberCount = 51;
    }else if(userItem.followers_count.length == 6){
        numeberCount = 61;
    }else if(userItem.followers_count.length == 7){
        numeberCount = 71;
    }else{
        numeberCount = 81;
    }
    
    UILabel * followCountLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-1)/2.0-34-numeberCount,  signLabel.frame.origin.y+signLabel.frame.size.height+20,numeberCount, 18)];
    followCountLabel.font = [UIFont systemFontOfSize:18];
    followCountLabel.textColor = CT_HEADER_WHITE_COLOR;
    followCountLabel.text = userItem.followers_count;
    [headBackGroundView addSubview:followCountLabel];
    UILabel * followLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-1)/2.0-34-followCountLabel.frame.size.width-30,  signLabel.frame.origin.y+signLabel.frame.size.height+25, 25, 12)];
    followLabel.font = [UIFont systemFontOfSize:12];
    followLabel.textColor = CT_HEADER_WHITE_COLOR;
    followLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_follow" withValue:nil withTable:@"Language"];
    [headBackGroundView addSubview:followLabel];
    UIButton * followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    followBtn.frame = CGRectMake((CT_HEADER_SCREEN_WIDTH/2.0 - 100), signLabel.frame.origin.y+signLabel.frame.size.height+25, 100, 18);
    [followBtn addTarget:self action:@selector(followBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [headBackGroundView addSubview:followBtn];
    
    
    
    UILabel * fansLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-1)/2.0+34, signLabel.frame.origin.y+signLabel.frame.size.height+25, 25, 12)];
    fansLabel.font = [UIFont systemFontOfSize:12];
    fansLabel.textColor = CT_HEADER_WHITE_COLOR;
    fansLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_fans" withValue:nil withTable:@"Language"];
    [headBackGroundView addSubview:fansLabel];
    UILabel * fansCountLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-1)/2.0+34+25+5,  signLabel.frame.origin.y+signLabel.frame.size.height+20, 100, 18)];
    fansCountLabel.font = [UIFont systemFontOfSize:18];
    fansCountLabel.textColor = CT_HEADER_WHITE_COLOR;
    fansCountLabel.text = userItem.friends_count;
    [headBackGroundView addSubview:fansCountLabel];
    UIButton * fansBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    fansBtn.frame = CGRectMake((CT_HEADER_SCREEN_WIDTH/2.0), signLabel.frame.origin.y+signLabel.frame.size.height+25, 100, 18);
    [fansBtn addTarget:self action:@selector(fenceBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [headBackGroundView addSubview:fansBtn];
    
    
    
    //关注微博&进入店铺
    
    if (isVip == YES) {
        UIButton * followWeiboBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        followWeiboBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0-15-80, followLabel.frame.origin.y+followLabel.frame.size.height+22, 80, 30);
        [followWeiboBtn setBackgroundImage:[UIImage imageNamed:@"guanzhuweibo_bg"] forState:UIControlStateNormal];
        [followWeiboBtn addTarget:self action:@selector(followWeiboBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [headBackGroundView addSubview:followWeiboBtn];
        UIImageView * followImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 7.5, 15, 15)];
        followImageView.image = [UIImage imageNamed:@"weibo"];
        [followWeiboBtn addSubview:followImageView];
        UILabel * followWeiboLabel = [[UILabel alloc] initWithFrame:CGRectMake(5+15+4,8.5, 56, 13)];
        followWeiboLabel.textColor = CT_HEADER_WHITE_COLOR;
        followWeiboLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_followWeibo" withValue:nil withTable:@"Language"];
        followWeiboLabel.font = [UIFont systemFontOfSize:13];
        [followWeiboBtn addSubview:followWeiboLabel];
        
        
        UIButton * enterShopBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        enterShopBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH/2.0+15, fansLabel.frame.origin.y+fansLabel.frame.size.height+22, 80, 30);
        [enterShopBtn setBackgroundImage:[UIImage imageNamed:@"jinrudianpu_bg"] forState:UIControlStateNormal];
        [enterShopBtn addTarget:self action:@selector(enterShopBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [headBackGroundView addSubview:enterShopBtn];
        UIImageView * enterShopImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 7.5, 15, 15)];
        enterShopImageView.image = [UIImage imageNamed:@"dianpu"];
        [enterShopBtn addSubview:enterShopImageView];
        UILabel * enterShopLabel = [[UILabel alloc] initWithFrame:CGRectMake(5+15+4,8.5, 56, 13)];
        enterShopLabel.textColor = CT_HEADER_WHITE_COLOR;
        enterShopLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_enterShop" withValue:nil withTable:@"Language"];
        enterShopLabel.font = [UIFont systemFontOfSize:13];
        [enterShopBtn addSubview:enterShopLabel];
        
        
    }else{
        
    }
    
    
    
    __weak CTUserView * vi = self;
    
    //选择器
    segmentView = [[CTSegmentView alloc] initWithFrame:CGRectMake(0, headOriginalImageView.frame.size.height, CT_HEADER_SCREEN_WIDTH, 51) withVip:isVip withSelf:isSelf];
    segmentView.tag = 10000;
    [headBackGroundView addSubview:segmentView];
    [segmentView setPressedHandler:^(CTSegmentViewType type, UIButton * btn) {
        switch (type) {
            case CTSegmentViewTypePublistTable:
                [vi seledd:type with:btn];
                break;
            case CTSegmentViewTypePublistCollection:
                [vi seledd:type with:btn];
                break;
            case CTSegmentViewTypeFavorite:
                [vi seledd:type with:btn];
                break;
            case CTSegmentViewTypeSubject:
                [vi seledd:type with:btn];
                break;
            default:
                break;
        }
    }];
    
//    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0,segmentView.origin.y+segmentView.size.height-0.5, CT_HEADER_SCREEN_WIDTH, 0.5)];
//    lineView.backgroundColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
//    [headBackGroundView addSubview:lineView];
    
    headBackGroundView.frame = CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, segmentView.origin.y+segmentView.size.height);
    
    
    return headBackGroundView;
}


-(void)creatNoDataView
{
    if (backNodatagroundView != nil) {
        [backNodatagroundView removeFromSuperview];
        backNodatagroundView = nil;
    }
    
    float nodataViewHeight = 0;
    
    if (pushType == CTUserViewPushFromTypeOther) {
        DeviceTypeAdaptation adapation = [CTDeviceFunction deviceTypeForResolutionAdaptation];
        if (adapation == iPhone4_4s) {
            nodataViewHeight = 0;
        }else if (adapation == iPhone5_5s_5c)
        {
            nodataViewHeight = 0;
        }else if (adapation == iPhone6)
        {
            nodataViewHeight = 0;
        }else if (adapation == iPhone6_Plus)
        {
            nodataViewHeight = 70;
        }
        
    }else{
        DeviceTypeAdaptation adapation = [CTDeviceFunction deviceTypeForResolutionAdaptation];
        if (adapation == iPhone4_4s) {
            nodataViewHeight = -30;
        }else if (adapation == iPhone5_5s_5c)
        {
            nodataViewHeight = -30;
        }else if (adapation == iPhone6)
        {
            nodataViewHeight = 0;
        }else if (adapation == iPhone6_Plus)
        {
            nodataViewHeight = 70;
        }
    }
    
    
    
    backNodatagroundView = [[UIView alloc] initWithFrame:CGRectMake(0,386 +nodataViewHeight, CT_HEADER_SCREEN_WIDTH, 184)];
    backNodatagroundView.backgroundColor = [UIColor clearColor];
    [self addSubview:backNodatagroundView];
    
    UIImageView * notLoginInImageView = [[UIImageView alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH - 90.5)/2.0, 0, 90.5, 108)];
    notLoginInImageView.image = [UIImage imageNamed:@"wuneirong"];
    [backNodatagroundView addSubview:notLoginInImageView];
    
    UILabel * remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,notLoginInImageView.frame.size.height + 15.0, CT_HEADER_SCREEN_WIDTH, 18.0)];
    remindLabel.textAlignment = NSTextAlignmentCenter;
    remindLabel.font = [UIFont systemFontOfSize:18.0];
    remindLabel.text = @"当前还没有内容哦!";
    remindLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    [backNodatagroundView addSubview:remindLabel];
    
}

-(void)seledd:(CTSegmentViewType)type with:(UIButton *)btn
{
    if (type == CTSegmentViewTypePublistTable)
    {
        [publishTableListView setHeadView: [self headView:is_vip withSelf:is_self]];
        
        publishTableListView.hidden = NO;
        subjectListCollectionView.hidden = YES;
        publishCollectionListView.hidden = YES;
        
        if (userPublishArray.count != 0) {
            [backNodatagroundView removeFromSuperview];
            backNodatagroundView = nil;
        }
    }
    else if (type == CTSegmentViewTypePublistCollection)
    {
        [publishCollectionListView setHeadView: [self headView:is_vip withSelf:is_self]];
        
        publishTableListView.hidden = YES;
        subjectListCollectionView.hidden = YES;
        publishCollectionListView.hidden = NO;
        
        if (userPublishArray.count != 0) {
            [backNodatagroundView removeFromSuperview];
            backNodatagroundView = nil;
        }
    }
    else if (type == CTSegmentViewTypeFavorite)
    {
        
    }
    else if (type == CTSegmentViewTypeSubject)
    {
        
        [subjectListCollectionView setHeadView:[self headView:is_vip withSelf:is_self]];
        
        publishTableListView.hidden = YES;
        subjectListCollectionView.hidden = NO;
        publishCollectionListView.hidden = YES;

        [self creatNoDataView];
    }
}







//登录界面

-(void)creatNotLoginView
{
    [backNodatagroundView removeFromSuperview];
    backNodatagroundView = nil;
    
    
    loginBackGroundView = [[UIView alloc] initWithFrame:self.bounds];
    loginBackGroundView.backgroundColor = [UIColor clearColor];
    [self addSubview:loginBackGroundView];
    
    
    topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 64)];
    topView.backgroundColor = CT_HEADER_WHITE_COLOR;
    [loginBackGroundView addSubview:topView];
    
    UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH-80.0)/2.0, 24, 80, 40)];
    titleLabel.textColor = CT_HEADER_GREEN_COLOR;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont systemFontOfSize:20];
    titleLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_titleLabel" withValue:nil withTable:@"Language"];
    [topView addSubview:titleLabel];
    
    UIButton * setBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    setBtn.frame = CGRectMake(CT_HEADER_SCREEN_WIDTH-44,24,44,44);
    [setBtn addTarget:self action:@selector(setBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [setBtn setTitleColor:CT_HEADER_WHITE_COLOR forState:UIControlStateNormal];
    [setBtn setBackgroundImage:[UIImage imageNamed:@"settings_two"] forState:UIControlStateNormal];
    [topView addSubview:setBtn];
    
    UILabel * topBottomLine = [[UILabel alloc]initWithFrame:CGRectMake(0, topView.height-0.5, CT_HEADER_SCREEN_WIDTH, 0.5)];
    topBottomLine.backgroundColor = CT_HEADER_DEEPLINE_COLOR;
    [topView addSubview:topBottomLine];

    
    
    UIView * backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CT_HEADER_SCREEN_WIDTH, 184)];
    backgroundView.backgroundColor = [UIColor clearColor];
    backgroundView.center = self.center;
    [loginBackGroundView addSubview:backgroundView];
    
    UIImageView * notLoginInImageView = [[UIImageView alloc] initWithFrame:CGRectMake((CT_HEADER_SCREEN_WIDTH - 90.5)/2.0, 0, 90.5, 108)];
    notLoginInImageView.image = [UIImage imageNamed:@"wuneirong"];
    [backgroundView addSubview:notLoginInImageView];
    
    UILabel * remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,notLoginInImageView.frame.size.height + 5.0, CT_HEADER_SCREEN_WIDTH, 18.0)];
    remindLabel.textAlignment = NSTextAlignmentCenter;
    remindLabel.font = [UIFont systemFontOfSize:18.0];
    remindLabel.text = [CTAppLanguage localizedStringForKey:@"userView_label_notlogin" withValue:nil withTable:@"Language"];
    remindLabel.textColor = [UIColor colorWithRed:164/255.0 green:164/255.0 blue:164/255.0 alpha:1.0];
    [backgroundView addSubview:remindLabel];
    
    UIButton * loginBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    loginBtn.frame = CGRectMake((CT_HEADER_SCREEN_WIDTH - 59)/2.0,notLoginInImageView.frame.size.height + remindLabel.frame.size.height + 5.0+20.0,59,28);
    [loginBtn addTarget:self action:@selector(loginBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [loginBtn setTitleColor:CT_HEADER_GREEN_COLOR forState:UIControlStateNormal];
    loginBtn.layer.borderWidth = 1;
    loginBtn.layer.masksToBounds = YES;
    loginBtn.layer.cornerRadius = 3;
    loginBtn.layer.borderColor = CT_HEADER_GREEN_COLOR.CGColor;
    [loginBtn setTitle:[CTAppLanguage localizedStringForKey:@"userView_btn_login" withValue:nil withTable:@"Language"] forState:UIControlStateNormal];
    loginBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [backgroundView addSubview:loginBtn];
    
    
    
    
}




#pragma mark - publish table view list delegate -

/**
 *@brief 点击评论总数
 */
- (void)userPublishTableListCommentCountAction:(CTUserPublishTableListView *)view withItem:(CTFollowList *)item
{
    if ([self.delegate respondsToSelector:@selector(commentCountActionItem:)]) {
        [self.delegate commentCountActionItem:item];
    }
}
/**
 *@brief 点击评论第一条
 */
- (void)userPublishTableListCommentHitFirstLabelAction:(CTUserPublishTableListView *) view withItem:(CTFollowList *)item
{
    if ([self.delegate respondsToSelector:@selector(commentHitFirstLabelActionItem:)]) {
        [self.delegate commentHitFirstLabelActionItem:item];
    }
}
/**
 *@brief 点击评论第二条
 */
- (void)userPublishTableListCommentHitSecondLabelAction:(CTUserPublishTableListView *) view withItem:(CTFollowList *)item
{
    if ([self.delegate respondsToSelector:@selector(commentHitSecondLabelActionItem:)]) {
        [self.delegate commentHitSecondLabelActionItem:item];
    }
}
/**
 *@brief 点击评论第一条头像
 */
- (void)userPublishTableListCommentHitFirstHeadAction:(CTUserPublishTableListView *)view withItem:(CTComment *) item
{
    if ([self.delegate respondsToSelector:@selector(commentHitFirstHeadActionItem:)]) {
        [self.delegate commentHitFirstHeadActionItem:item];
    }
}
/**
 *@brief 点击评论第二条头像
 */
- (void)userPublishTableListCommentHitSecondHeadAction:(CTUserPublishTableListView *)view withItem:(CTComment *)item
{
    if ([self.delegate respondsToSelector:@selector(commentHitSecondHeadActionItem:)]) {
        [self.delegate commentHitSecondHeadActionItem:item];
    }
}
/**
 *@brief 点击头像
 */
- (void)userPublishTableListHitHeadAction:(CTUserPublishTableListView *)view withItem:(CTFollowList *)item
{
    if ([self.delegate respondsToSelector:@selector(hitHeadActionItem:)]) {
        [self.delegate hitHeadActionItem:item];
    }
}
/**
 *@brief 点击大图
 */
- (void)userPublishTableListHitPicImageBtnAction:(CTUserPublishTableListView *)view withItem:(CTFollowList *)item withImageView:(UIImageView *)picImageView
{
    if ([self.delegate respondsToSelector:@selector(hitPicImageBtnActionItem:withImageView:)]) {
        [self.delegate hitPicImageBtnActionItem:item withImageView:picImageView];
    }
}
/**
 *@brief 点赞
 */
- (void)userPublishTableListHitFavourBtnAction:(CTUserPublishTableListView *)view withItem:(CTFollowList *)item withBool:(BOOL) favBool
{
    if ([self.delegate respondsToSelector:@selector(hitFavourBtnActionItem:withBool:)]) {
        [self.delegate hitFavourBtnActionItem:item withBool:favBool];
    }
}
/**
 *@brief 点击评论按钮
 */
- (void)userPublishTableListHitCommentBtnaction:(CTUserPublishTableListView *) view withItem:(CTFollowList *)item
{
    if ([self.delegate respondsToSelector:@selector(hitCommentBtnactionItem:)]) {
        [self.delegate hitCommentBtnactionItem:item];
    }
}
/**
 *@brief 点击分享按钮
 */
- (void)userPublishTableListHitShareBtnAction:(CTUserPublishTableListView *) view withItem:(CTFollowList *)item withImage:(UIImage *)img
{
    if ([self.delegate respondsToSelector:@selector(hitShareBtnActionItem:withImage:)]) {
        [self.delegate hitShareBtnActionItem:item withImage:img];
    }
}
/**
 *@brief 点击更多按钮
 */
- (void)userPublishTableListHitMoreBtnAction:(CTUserPublishTableListView *) view withItem:(CTFollowList *)item
{
    if ([self.delegate respondsToSelector:@selector(hitMoreBtnActionItem:)]) {
        [self.delegate hitMoreBtnActionItem:item];
    }
}
/**
 *@brief 点击点赞的人的头像
 */
- (void)userPublishTableListHitFavBtnHeadAction:(CTUserPublishTableListView *)view withItem:(CTListDetailUser *)item
{
    if ([self.delegate respondsToSelector:@selector(hitFavBtnHeadActionItem:)]) {
        [self.delegate hitFavBtnHeadActionItem:item];
    }
}
/**
 *@brief 点击关注按钮
 */
- (void)userPublishTableListHitAttentionBtnAction:(CTUserPublishTableListView *) view withItem:(CTFollowList *)item withBool:(BOOL) attenBool
{
    if ([self.delegate respondsToSelector:@selector(hitAttentionBtnActionItem:withBool:)]) {
        [self.delegate hitAttentionBtnActionItem:item withBool:attenBool];
    }
}
/**
 *@brief 点击话题
 */
- (void)userPublishTableListHitTopicBtnAction:(CTUserPublishTableListView *) view withItem:(CTTopic *)item
{
    if ([self.delegate respondsToSelector:@selector(hitTopicBtnActionItem:)]) {
        [self.delegate hitTopicBtnActionItem:item];
    }
}


- (void)userPublishTableListScrollViewDidScroll:(UIScrollView *)scrollView
{
    //tabbar色值渐变
    if (scrollView.contentOffset.y-(offset_height-tabbarHeight) >= 0) {
        if (scrollView.contentOffset.y-(offset_height-tabbarHeight) > 64) {
            topView.backgroundColor = CT_HEADER_GREEN_COLOR;
            topView.alpha = 1.0;
        }else{
            topView.backgroundColor = CT_HEADER_GREEN_COLOR;
            topView.alpha = (0.85/64.0)*(scrollView.contentOffset.y-(offset_height-tabbarHeight));
        }
    }else{
        topView.backgroundColor = CT_HEADER_WHITE_COLOR;
        topView.alpha = 0.15;
    }
//
//    
//    //背景图片缩放
//    if ((-scrollView.contentOffset.y) >= 0) {
//        CGRect frame = CGRectMake(-(-scrollView.contentOffset.y)*1+offset_x,-(-scrollView.contentOffset.y)*2+offset_y,offset_with + (-scrollView.contentOffset.y)*2, offset_height + (-scrollView.contentOffset.y)*2);
//        headOriginalImageView.frame = frame;
//        headShadowView.frame = headOriginalImageView.bounds;
//        
//        
//        //毛玻璃透明度
//        if ((-scrollView.contentOffset.y) != 0){
//            float offset;
//            if ((-scrollView.contentOffset.y)>=200.0) {
//                offset = 200.0;
//            }else{
//                if ((-scrollView.contentOffset.y)>10) {
//                    offset = (-scrollView.contentOffset.y);
//                }else
//                {
//                    offset = 10.0;
//                }
//                
//            }
//            [CTImageProcessing blurryImage:headOriginalImage withBlurLevel:0.4*(10.0/offset) withCompletionHandeler:^(UIImage *img){
//                headOriginalImageView.image = img;
//            }];
//        }
//        
//        if ((-scrollView.contentOffset.y) == 0){
//            [CTImageProcessing blurryImage:headOriginalImage withBlurLevel:0.4 withCompletionHandeler:^(UIImage *img) {
//                headOriginalImageView.image = img;
//            }];
//        }
//        
//    }else{
//        
//    }
}


//刷新
-(void)refreshControlPullDown:(CTUserPublishTableListView *)view
{
    if ([self.delegate respondsToSelector:@selector(refreshPTControlPullDown)]) {
        [self.delegate refreshPTControlPullDown];
    }
}
-(void)refreshControlPullUp:(CTUserPublishTableListView *)view
{
    if([self.delegate respondsToSelector:@selector(refreshPTControlPullUp)]) {
        [self.delegate refreshPTControlPullUp];
    }
}


#pragma mark - user publish collection delegate -

-(void)userPublishCollectionListViewClicked:(CTUserPublishCollectionListView *)view withItem:(CTFollowList *)item
{
    if ([self.delegate respondsToSelector:@selector(collectionListViewClickedItem:)]) {
        [self.delegate collectionListViewClickedItem:item];
    }
}

-(void)userPublishCollectionListScrollViewDidScroll:(UIScrollView *)scrollView
{
    //tabbar色值渐变
    if (scrollView.contentOffset.y-(offset_height-tabbarHeight) >= 0) {
        if (scrollView.contentOffset.y-(offset_height-tabbarHeight) > 64) {
            topView.backgroundColor = CT_HEADER_GREEN_COLOR;
            topView.alpha = 1.0;
        }else{
            topView.backgroundColor = CT_HEADER_GREEN_COLOR;
            topView.alpha = (0.85/64.0)*(scrollView.contentOffset.y-(offset_height-tabbarHeight));
        }
    }else{
        topView.backgroundColor = CT_HEADER_WHITE_COLOR;
        topView.alpha = 0.15;
    }
}

//刷新
-(void)refreshPublishCollectionControlPullDown:(CTUserPublishCollectionListView *)view
{
    if([self.delegate respondsToSelector:@selector(refreshPCControlPullDown)]) {
        [self.delegate refreshPCControlPullDown];
    }
}
-(void)refreshPublishCollectionControlPullUp:(CTUserPublishCollectionListView *)view
{
    if([self.delegate respondsToSelector:@selector(refreshPCControlPullUp)]) {
        [self.delegate refreshPCControlPullUp];
    }
}




#pragma mark - user subject collection delegate -

//刷新
-(void)refreshSubjectCollectionControlPullDown:(CTUserSubjectsList *)view
{
    if([self.delegate respondsToSelector:@selector(refreshSCControlPullDown)]) {
        [self.delegate refreshSCControlPullDown];
    }
}
-(void)refreshSubjectCollectionControlPullUp:(CTUserSubjectsList *)view
{
    if([self.delegate respondsToSelector:@selector(refreshSCControlPullUp)]) {
        [self.delegate refreshSCControlPullUp];
    }
}

-(void)userSubjectPublishCollectionListViewClicked:(CTUserSubjectsList *)view
{
    
}

-(void)userSubjectPublishCollectionListScrollViewDidScroll:(UIScrollView *)scrollView
{
    //tabbar色值渐变
    if (scrollView.contentOffset.y-(offset_height-tabbarHeight) >= 0) {
        if (scrollView.contentOffset.y-(offset_height-tabbarHeight) > 64) {
            topView.backgroundColor = CT_HEADER_GREEN_COLOR;
            topView.alpha = 1.0;
        }else{
            topView.backgroundColor = CT_HEADER_GREEN_COLOR;
            topView.alpha = (0.85/64.0)*(scrollView.contentOffset.y-(offset_height-tabbarHeight));
        }
    }else{
        topView.backgroundColor = CT_HEADER_WHITE_COLOR;
        topView.alpha = 0.15;
    }
}





#pragma mark - action & delegate -

-(void)attentionBtnAction:(id)sender
{
    UIButton * btn = (UIButton *)sender;
    if (btn.tag == 0) {
        //要关注
        btn.tag = 1;
        [btn setTitle:@"取消关注" forState:UIControlStateNormal];
        if ([self.delegate respondsToSelector:@selector(attention:withBool:)]) {
            [self.delegate attention:self withBool:YES];
        }
        
    }else{
        //要取消关注
        btn.tag = 0;
        [btn setTitle:@"加关注" forState:UIControlStateNormal];
        if ([self.delegate respondsToSelector:@selector(attention:withBool:)]) {
            [self.delegate attention:self withBool:NO];
        }
    }
}

-(void)setBtnAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(setsAction:)]) {
        [self.delegate setsAction:self];
    }
}
-(void)loginBtnAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(loginAction:)]) {
        [self.delegate loginAction:self];
    }
}
-(void)followWeiboBtnAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(verifiedWeiboAction:)]) {
        [self.delegate verifiedWeiboAction:self];
    }
}
-(void)enterShopBtnAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(verifiedShopAction:)]) {
        [self.delegate verifiedShopAction:self];
    }
}

-(void)followBtnAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(followAction:)]) {
        [self.delegate followAction:self];
    }
}

-(void)fenceBtnAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(fenceAction:)]) {
        [self.delegate fenceAction:self];
    }
}

-(void)backBtnAction:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(backAction:)]) {
        [self.delegate backAction:self];
    }
}

-(void)showSignBtnAction:(id)sender
{
    UIButton * btn = (UIButton *)sender;
    switch (btn.tag) {
        case CTUserViewSignTypeShowHalf:
            signType = CTUserViewSignTypeShowAll;
            break;
        case CTUserViewSignTypeShowAll:
            signType = CTUserViewSignTypeShowHalf;
            break;
        default:
            break;
    }
    [self reloadViews];
}


#pragma mark - reload view -
-(void)drawRect:(CGRect)rect
{

    [currentHeaderView removeFromSuperview];
    currentHeaderView = nil;
    
    [loginBackGroundView removeFromSuperview];
    loginBackGroundView = nil;

    
    [self creatSubviews];
    
}
-(void)reloadViews
{
    [self performSelectorOnMainThread:@selector(viewNeedsDisplayOnMainThread) withObject:nil waitUntilDone:NO];
}

-(void)reloadTables
{
    if (publishTableListView != nil)[publishTableListView reloadData];
    if (publishCollectionListView != nil)[publishCollectionListView reloadData];
    if (subjectListCollectionView != nil)[subjectListCollectionView reloadData]; 
}

-(void)viewNeedsDisplayOnMainThread
{
    [self setNeedsDisplay];
}




-(void)refreshPublishTable
{
    if (publishTableListView != nil)[publishTableListView refresh];
}
-(void)refreshPublishTableEnd
{
    if (publishTableListView != nil)[publishTableListView refreshPullDownEnd];
}

-(void)refreshPublishCollection
{
    if (publishCollectionListView != nil)[publishCollectionListView refresh];
}
-(void)refreshPublishCollectionEnd
{
    if (publishCollectionListView != nil)[publishCollectionListView refreshPullDownEnd];
}

-(void)refreshSubjectCollection
{
    if (subjectListCollectionView != nil)[subjectListCollectionView refresh];
}
-(void)refreshSubjectCollectionEnd
{
    if (subjectListCollectionView != nil)[subjectListCollectionView refreshPullDownEnd];
}






#pragma mark - setter -
-(void)setPushType:(CTUserViewPushFromType)type
{
    pushType = type;
}

-(void)setUserPublishArr:(NSArray *)publishArr
{
    userPublishArray = publishArr;
    [self reloadViews];
}

@end
